package com.lx.zxs.service;

import com.lx.zxs.mapper.CommentMapper;
import com.lx.zxs.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class CommentService {

    @Autowired
    private CommentMapper commentMapper;
    public List<Map> getCommentByVideoId(Integer id) {
        List<Map> list = commentMapper.getCommentByVideoId(id);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        for(Map map: list){
            Date cdate = (Date) map.get("cdate");
            String format = sdf.format(cdate);
            map.put("cdate",format);
        }

        return list;
    }

    public void addComment(Integer uid,Integer vid,String content,String cdate) {
        commentMapper.addComment(uid,vid,content,cdate);
    }
}
